<?php

namespace app\admin\model;

use app\common\basic\BaseModel;
use app\common\model\Batch;
use app\common\model\Dealer;

/**
 * 商品模型
 */
class Goods extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';
    protected $table = 'vk_goods';
    
    public function spec() {
        return $this->hasMany(GoodsSpec::class, 'goods_id', 'id')->order('unit_type', 'desc');
    }

    public function batches() {
        return $this->hasMany(Batch::class, 'goods_id', 'id');
    }
    
    public function dealer() {
        return $this->belongsTo(Dealer::class, 'dealer_id', 'id');
    }
    
}